Page({
  // 转发二维码
  onShareAppMessage() {
    return {
      title: '查看通行证',
      path: '/visitor_pkg/pages/passport/index',
      imageUrl: 'https://enjoy-plus.oss-cn-beijing.aliyuncs.com/images/share_poster.png',
    }
  },
  onLoad({ id }) {
    // console.log(id)
    this.getVisitorDetail(id)
  },
  // 查询访客邀请详情
  async getVisitorDetail(id) {
    if (!id) return
    const res = await wx.http.get(`/visitor/${id}`)
    // console.log(res, '获取访客详情')
    // 将数据保存到data中
    this.setData({
      ...res.data
    })
  },
  // 保存到本地
  async saveImage() {
    const { path } = await wx.getImageInfo({
      src: this.data.url,
    })
    console.log(path)
    wx.saveImageToPhotosAlbum({
      filePath: path,
      success: () => {
        wx.utils.toast('保存成功')
      }
    })
  }
})
